# -*- coding: utf-8 -*-

from datetime import datetime
from pydantic import BaseModel, validator
from typing import Any, Dict

from app.models.request import BaseModelLocal
from app.models.request.role import Role

class UserBase(BaseModel):
    account: str | None = None
    # username = str
    nickname: str | None = None
    real_name: str | None = None
    user_type: int | None = None
    email: str | None = None
    mobile: str | None = None
    gender: int | None = None
    birthday: datetime | None = None
    signature: str | None = None
    # self_signature: str | None = None
    avatar: str | None = None


class UserCreate(UserBase):
    password: str
    invite_code: str | None = None
    

class UserUpdate(UserBase):
    status: int | None = None
    extra: Dict[str, Any] | None = None
    remark: str | None = None
    


class User(UserBase, BaseModelLocal):
    status: int | None = None
    login_ip: str | None = None
    lasted: datetime | None = None
    extra: Dict[str, Any] | None = None
    remark: str | None = None
    create_source: str | None = None
    class Config:
        from_attributes = True
    
class UserRoleIn(BaseModel):
    roles: list[int] | None = None
    class Config:
        from_attributes = True
    
class UserRole(User):
    roles: list[Role] | None = None
    class Config:
        from_attributes = True
    